package com.isyscore.log;

import ch.qos.logback.core.PropertyDefinerBase;
import lombok.extern.slf4j.Slf4j;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @Author: liuxq@isyscore.com
 * @Date: 2021-04-26 15:50:43
 * @Description:
 */
@Slf4j
public class LogHostNamePropertyDefiner extends PropertyDefinerBase {

    @Override
    public String getPropertyValue() {
        InetAddress address;
        try {
            address = InetAddress.getLocalHost();

            return address.getHostName();
        } catch (UnknownHostException e) {
            log.error("获取host异常", e);
        }
        return "";
    }
}
